from django.db import models
from django.contrib.auth.models import User

# Create your models here.

class Actor(models.Model):
	name = models.TextField(max_length = 50)
	birthYear = models.IntegerField()
	birthPlace = models.TextField(max_length = 50)
	nationality = models.TextField(max_length = 50)

	def __unicode__(self):
		return self.name

class Director(models.Model):
	name = models.TextField(max_length = 50)
	birthYear = models.IntegerField()
	birthPlace = models.TextField(max_length = 50)
	nationality = models.TextField(max_length = 50)
	def __unicode__(self):
		return self.name


class Film (models.Model):
	title = models.TextField(max_length = 50)
	year = models.IntegerField()
	duration = models.IntegerField()
	category = models.TextField(max_length = 50)
	director = models.ForeignKey(Director)
	actors = models.ManyToManyField(Actor)
	def __unicode__(self):
		return self.title


class Qualification(models.Model):
	rating = models.FloatField()
	review = models.TextField(max_length = 500)
	user = models.ForeignKey(User)
	film = models.ForeignKey(Film)
	def __unicode__(self):
		return self.film.title	 +" by "+self.user.username


